package com.ruoyi.web.controller.solidDispose;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.solidDispose.domain.GfEp;
import com.ruoyi.solidDispose.service.IGfEpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 固废处置企业Controller
 * 
 * @author ruoyi
 * @date 2021-09-02
 */
@RestController
@RequestMapping("/solidDispose/gfEp")
public class GfEpController extends BaseController
{
    @Autowired
    private IGfEpService gfEpService;

    /**
     * 查询固废处置企业列表
     */
    @PreAuthorize("@ss.hasPermi('solidDispose:gfEp:list')")
    @GetMapping("/list")
    public TableDataInfo list(GfEp gfEp)
    {
        startPage();
        List<GfEp> list = gfEpService.selectGfEpList(gfEp);
        return getDataTable(list);
    }

    /**
     * 导出固废处置企业列表
     */
    @PreAuthorize("@ss.hasPermi('solidDispose:gfEp:export')")
    @Log(title = "固废处置企业", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GfEp gfEp)
    {
        List<GfEp> list = gfEpService.selectGfEpList(gfEp);
        ExcelUtil<GfEp> util = new ExcelUtil<GfEp>(GfEp.class);
        return util.exportExcel(list, "固废处置企业数据");
    }

    /**
     * 获取固废处置企业详细信息
     */
    @PreAuthorize("@ss.hasPermi('solidDispose:gfEp:query')")
    @GetMapping(value = "/{gfId}")
    public AjaxResult getInfo(@PathVariable("gfId") Long gfId)
    {
        return AjaxResult.success(gfEpService.selectGfEpById(gfId));
    }

    /**
     * 新增固废处置企业
     */
    @PreAuthorize("@ss.hasPermi('solidDispose:gfEp:add')")
    @Log(title = "固废处置企业", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GfEp gfEp)
    {
        return toAjax(gfEpService.insertGfEp(gfEp));
    }

    /**
     * 修改固废处置企业
     */
    @PreAuthorize("@ss.hasPermi('solidDispose:gfEp:edit')")
    @Log(title = "固废处置企业", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GfEp gfEp)
    {
        return toAjax(gfEpService.updateGfEp(gfEp));
    }

    /**
     * 删除固废处置企业
     */
    @PreAuthorize("@ss.hasPermi('solidDispose:gfEp:remove')")
    @Log(title = "固废处置企业", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gfIds}")
    public AjaxResult remove(@PathVariable Long[] gfIds)
    {
        return toAjax(gfEpService.deleteGfEpByIds(gfIds));
    }
}
